<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\api\controller\v1\publics;

use app\Request;
use app\services\gowifarticle\GowifArticleServices;
use think\facade\App;

/**
 * 文章管理
 * Class Article
 * @package app\adminapi\controller\v1\cms
 */
class GowifController
{
    /**
     * @var GowifArticleServices
     */
    protected $service;

    /**
     * Article constructor.
     * @param App $app
     * @param GowifArticleServices $service
     */
    public function __construct(App $app, GowifArticleServices $service)
    {
        $this->service = $service;
    }

    /**
     * 获取列表
     * @return mixed
     */
    public function index(Request $request)
    {
        $where = $request->getMore([
            ['title', ''],
            ['cid', 0],
            ['add_time_start',''],
            ['add_time_end',''],
        ]);
        $data = $this->service->getList($where);
        if($data['count'] > 0){
            foreach ($data['list'] as $key => $item){
                unset($data['list'][$key]['author']);
                unset($data['list'][$key]['content']);
                unset($data['list'][$key]['visit']);
                unset($data['list'][$key]['status']);
                unset($data['list'][$key]['hide']);
                unset($data['list'][$key]['admin_id']);
                unset($data['list'][$key]['admin_name']);
            }
        }
        return app('json')->success($data);
    }

    /**
     * 保存设置
     * @return mixed
     */
    public function read($id)
    {
        $data = $this->service->read($id);
        return app('json')->success($data);
    }
}
